﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Microsoft.Extensions.DependencyInjection;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace zijian666.DI;

[TestClass]
public class 多次添加注入测试
{
    [TestMethod]
    public void 多次添加()
    {
        var services = new ServiceCollection().AddComponents([typeof(MyClass)]);

        Assert.AreEqual(1, services.Count(x => x.ServiceType == typeof(MyClass)));

        services = services.AddComponents([typeof(MyClass)]);
        Assert.AreEqual(1, services.Count(x => x.ServiceType == typeof(MyClass)));

    }


    [Component]
    class MyClass
    {

    }
}
